Skip to content

IGNITE-28426 Fix bug preventing SqlDdlGenerator from converting value classes with nested pojos annotated with SqlQueryField#7912

Open
tmgodinho wants to merge 1 commit intoapache:mainfrom
tmgodinho:ignite-28426
Open

IGNITE-28426 Fix bug preventing SqlDdlGenerator from converting value classes with nested pojos annotated with SqlQueryField#7912
tmgodinho wants to merge 1 commit intoapache:mainfrom
tmgodinho:ignite-28426

Conversation

@tmgodinho
Copy link
Copy Markdown
Contributor

https://issues.apache.org/jira/browse/IGNITE-28426

What was done:

  • [] Fix bug preventing SqlDdlGenerator from converting value classes with nested pojos annotated with SqlQueryField

… classes with nested pojos annotated with SqlQueryField

** Added tests
@tmgodinho tmgodinho marked this pull request as ready for review April 2, 2026 09:31
@isapego isapego requested a review from Copilot April 10, 2026 11:00
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes an issue in the migration tools’ SQL DDL generation where value classes containing nested POJOs annotated with @QuerySqlField were not handled correctly during QueryEntity enrichment, preventing expected table definition generation.

Changes:

  • Add a regression test and a new test model covering a value class with an annotated nested POJO.
  • Adjust SqlDdlGenerator.populateQueryEntity to treat non-natively-supported QueryEntity field types as POJO-mapped and move them toward “extra fields” handling.
  • Expose TypeInspector.isPrimitiveType (with Javadoc) for cross-package reuse.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
migration-tools/modules/migration-tools-commons/src/test/java/org/apache/ignite/migrationtools/sql/sql/SqlDdlGeneratorTest.java Adds a parameterized regression test for nested annotated POJO handling.
migration-tools/modules/migration-tools-commons/src/main/java/org/apache/ignite/migrationtools/types/TypeInspector.java Makes isPrimitiveType public for use in SQL DDL generation logic.
migration-tools/modules/migration-tools-commons/src/main/java/org/apache/ignite/migrationtools/sql/SqlDdlGenerator.java Updates POJO detection and field handling logic during QueryEntity population.
migration-tools/modules/migration-tools-commons-tests/src/main/java/org/apache/ignite/migrationtools/tests/models/NestedPojoWithAnnotations.java Introduces a test model with @QuerySqlField on a primitive and a nested POJO field.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +437 to +456
// We also want to remove fields non-compliant with AI3 so that they are handled in the extra fields.
for (var e : qe.getFields().entrySet()) {
String fieldType = ClassnameUtils.ensureWrapper(e.getValue());

boolean isNativelySupportedType;
try {
Class<?> type = ClassUtils.getClass(this.clientClassLoader, fieldType);
isNativelySupportedType = TypeInspector.isPrimitiveType(type);
} catch (ClassNotFoundException ignored) {
// All natively supported types should be in the classpath.
// Some enums might still slip throught.
isNativelySupportedType = false;
}

// Remove from the field list, we will need to map it in the extra fields.
if (!isNativelySupportedType) {
mapsPojo = true;
qe.getFields().remove(e.getKey());
qe.getKeyFields().remove(e.getKey());
}
Copy link

Copilot AI Apr 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Modifying qe.getFields() while iterating qe.getFields().entrySet() (calling qe.getFields().remove(...) inside the enhanced for-loop) will throw ConcurrentModificationException for typical Map implementations (e.g., HashMap/LinkedHashMap). Collect keys to remove first (or use an explicit iterator and iterator.remove()), then update keyFields accordingly.

Copilot uses AI. Check for mistakes.
isNativelySupportedType = TypeInspector.isPrimitiveType(type);
} catch (ClassNotFoundException ignored) {
// All natively supported types should be in the classpath.
// Some enums might still slip throught.
Copy link

Copilot AI Apr 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo in comment: "slip throught" should be "slip through".

Suggested change
// Some enums might still slip throught.
// Some enums might still slip through.

Copilot uses AI. Check for mistakes.
Comment on lines +136 to +141
/**
* Whether the provided class, or it's derivatives, is natively supported.
*
* @param type Type.
* @return True or false.
*/
Copy link

Copilot AI Apr 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Grammar in Javadoc: "it's derivatives" should be "its derivatives" (possessive, not contraction).

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants